<template>
  <div class="md:flex">
    <template v-for="(item, index) in diyData" :key="item.title">
      <Card
        size="small"
        :loading="loading"
        class="md:w-1/4 w-full !md:mt-0"
        title="今日请求量"
        :class="{ '!md:mr-4': 0 + 1 < 4, '!mt-4': 0 > 0 }"
      >
        <div class="py-4 px-4 flex justify-between items-center">
          <CountTo prefix="" :startVal="1" :endVal="item.day_pv" class="text-2xl" />
          <Icon icon="visit-count|svg" :size="40" />
        </div>
      </Card>

      <Card
        size="small"
        :loading="loading"
        class="md:w-1/4 w-full !md:mt-0"
        title="总请求量"
        :class="{ '!md:mr-4': 0 + 1 < 4, '!mt-4': 0 > 0 }"
      >
        <div class="py-4 px-4 flex justify-between items-center">
          <CountTo prefix="" :startVal="1" :endVal="item.total_pv" class="text-2xl" />
          <Icon icon="total-sales|svg" :size="40" />
        </div>
      </Card>
      <Card
        size="small"
        :loading="loading"
        class="md:w-1/4 w-full !md:mt-0"
        title="服务器核心"
        :class="{ '!md:mr-4': 0 + 1 < 4, '!mt-4': 0 > 0 }"
      >
        <div class="py-4 px-4 flex justify-between items-center">
          <CountTo prefix="" :startVal="1" :endVal="item.cpu_count" class="text-2xl" />
          <Icon icon="download-count|svg" :size="40" />
        </div>
      </Card>
      <Card
        size="small"
        :loading="loading"
        class="md:w-1/4 w-full !md:mt-0"
        title="启用进程数量"
        :class="{ '!md:mr-4': 0 + 1 < 4, '!mt-4': 0 > 0 }"
      >
        <div class="py-4 px-4 flex justify-between items-center">
          <CountTo prefix="" :startVal="1" :endVal="item.server_count" class="text-2xl" />
          <Icon icon="transaction|svg" :size="40" />
        </div>
      </Card>
      <!-- <Card
        size="small"
        :loading="loading"
        :title="item.title"
        class="md:w-1/4 w-full !md:mt-0"
        :class="{ '!md:mr-4': index + 1 < 4, '!mt-4': index > 0 }"
      >
        <template #extra>
          <Tag :color="item.color">{{ item.action }}</Tag>
        </template>

        <div class="py-4 px-4 flex justify-between items-center">
          <CountTo prefix="$" :startVal="1" :endVal="item.value" class="text-2xl" />
          <Icon :icon="item.icon" :size="40" />
        </div>

        <div class="p-2 px-4 flex justify-between">
          <span>总{{ item.title }}</span>
          <CountTo prefix="$" :startVal="1" :endVal="item.total" />
        </div>
      </Card> -->
    </template>
  </div>

  <br />
  <div class="md:flex">
    <template v-for="(item, index) in diyData" :key="item.title">
      <Card
        size="small"
        :loading="loading"
        class="md:w-1/4 w-full !md:mt-0"
        title="Redis内存占用"
        :class="{ '!md:mr-4': 0 + 1 < 4, '!mt-4': 0 > 0 }"
      >
        <div class="py-4 px-4 flex justify-between items-center">
          <span style="font-size: 1.5rem; line-height: 2rem">
            {{ item.redis_used_memory_human }}
          </span>
          <Icon icon="visit-count|svg" :size="40" />
        </div>
      </Card>

      <Card
        size="small"
        :loading="loading"
        class="md:w-1/4 w-full !md:mt-0"
        title="当前Redis Key数量"
        :class="{ '!md:mr-4': 0 + 1 < 4, '!mt-4': 0 > 0 }"
      >
        <div class="py-4 px-4 flex justify-between items-center">
          <span style="font-size: 1.5rem; line-height: 2rem">
            {{ item.reids_keycount }}
          </span>
          <Icon icon="total-sales|svg" :size="40" />
        </div>
      </Card>
      <Card
        size="small"
        :loading="loading"
        class="md:w-1/4 w-full !md:mt-0"
        title="PHP Version"
        :class="{ '!md:mr-4': 0 + 1 < 4, '!mt-4': 0 > 0 }"
      >
        <div class="py-4 px-4 flex justify-between items-center">
          <span style="font-size: 1.5rem; line-height: 2rem">
            {{ item.php_version }}
          </span>
          <Icon icon="download-count|svg" :size="40" />
        </div>
      </Card>
      <Card
        size="small"
        :loading="loading"
        class="md:w-1/4 w-full !md:mt-0"
        title="Mysql Version"
        :class="{ '!md:mr-4': 0 + 1 < 4, '!mt-4': 0 > 0 }"
      >
        <div class="py-4 px-4 flex justify-between items-center">
          <span style="font-size: 1.5rem; line-height: 2rem">
            {{ item.mysql_version }}
          </span>
          <Icon icon="transaction|svg" :size="40" />
        </div>
      </Card>
      <!-- <Card
        size="small"
        :loading="loading"
        :title="item.title"
        class="md:w-1/4 w-full !md:mt-0"
        :class="{ '!md:mr-4': index + 1 < 4, '!mt-4': index > 0 }"
      >
        <template #extra>
          <Tag :color="item.color">{{ item.action }}</Tag>
        </template>

        <div class="py-4 px-4 flex justify-between items-center">
          <CountTo prefix="$" :startVal="1" :endVal="item.value" class="text-2xl" />
          <Icon :icon="item.icon" :size="40" />
        </div>

        <div class="p-2 px-4 flex justify-between">
          <span>总{{ item.title }}</span>
          <CountTo prefix="$" :startVal="1" :endVal="item.total" />
        </div>
      </Card> -->
    </template>
  </div>
</template>
<script lang="ts" setup>
  import { CountTo } from '/@/components/CountTo/index';
  import { Icon } from '/@/components/Icon';
  import { Card } from 'ant-design-vue';
  // import { growCardList, diyData } from '../data';
  import { getIndexData } from '/@/api/wbadmin/admin';

  import { ref } from 'vue';

  const diyData = ref();

  getIndexData().then(function (result) {
    diyData.value = result;
  });

  defineProps({
    loading: {
      type: Boolean,
    },
  });
</script>
